package cn.zjj.service.impl;

import cn.zjj.domain.Store;
import cn.zjj.mapper.StoreMapper;
import cn.zjj.service.IStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
@Service
public class StoreServiceImpl implements IStoreService {

    @Autowired
    private StoreMapper storeMapper;

    @Transactional
    @Override
    public Map<String, Object> add(Store store) {
        storeMapper.insert(store);
        Map<String,Object> map=new HashMap<>();
        map.put("success",true);
        map.put("message","添加成功");
        return map;
    }
    @Transactional
    @Override
    public Map<String, Object> update(Store store) {
        storeMapper.update(store);
        Map<String,Object> map=new HashMap<>();
        map.put("success",true);
        map.put("message","修改成功");
        return map;
    }

    @Override
    public Store selectById(Long product_id) {

        return storeMapper.selectById(product_id);
    }
}
